package com.qf.admin.web.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.admin.common.core.domain.MenuEnum;
import com.qf.admin.web.system.domain.entity.SysPermission;
import com.qf.admin.web.system.domain.form.MenuForm;
import com.qf.admin.web.system.domain.vo.MenuOptions;
import com.qf.admin.web.system.domain.vo.PermOptions;
import com.qf.admin.web.system.service.SysPermissionService;
import com.qf.admin.web.system.mapper.SysPermissionMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author sin
* @description 针对表【sys_permission(权限表)】的数据库操作Service实现
* @createDate 2024-06-11 11:35:22
*/
@Service
public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, SysPermission>
    implements SysPermissionService{

    @Resource
    SysPermissionMapper permissionMapper;

    @Override
    public List<String> selectPermsByUserId(Long uid) {
        return permissionMapper.selectPermsByUserId(uid);
    }

    /**
     * @description 获取所有按钮权限
     * @return java.util.List<com.qf.web.system.domain.entity.SysPermission>
     */
    @Override
    public List<SysPermission> selectAll() {
        return permissionMapper.selectList(null);
    }

    /**
     * @description 获取按钮权限
     * @return java.util.List<com.qf.web.system.domain.vo.MenuOptions>
     */
    @Override
    public List<MenuOptions> getBtnOptions() {
        return permissionMapper.getBtnOptions();
    }

    /**
     * @description 获取角色权限
     * @param roleId
     * @return java.util.List<java.lang.Long>
     */
    @Override
    public List<PermOptions> selectPermByRoleId(Long roleId) {
        return permissionMapper.selectPermByRoleId(roleId);
    }

    /**
     * @description 获取所有按钮权限的id
     * @return java.util.List<java.lang.Long>
     */
    @Override
    public List<Long> getBtnIds() {
        return permissionMapper.getBtnIds();
    }

    @Override
    public MenuForm getPermsById(Long id) {
        SysPermission permission = permissionMapper.getPermsById(id);
        MenuForm perm = new MenuForm(permission.getMenuId(), permission.getName(), MenuEnum.enumMap.get(3), permission.getBtnPerm());
        return perm;
    }

}




